package com.lb.shopguide.adapter.index;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lb.shopguide.R;
import com.lb.shopguide.constants.AppConstant;
import com.lb.shopguide.entity.ExpressBean;
import com.lb.shopguide.util.pic.ImageLoaderUtils;

import me.yokeyword.indexablerv.IndexableAdapter;

/**
 * Created by kang on 2017/6/5.
 */

public class AdapterIndexDelivery extends IndexableAdapter<ExpressBean> {

    private LayoutInflater mInflater;
    private Context mContext;

    public AdapterIndexDelivery(Context context) {
        mInflater = LayoutInflater.from(context);
        mContext = context;
    }

    @Override
    public RecyclerView.ViewHolder onCreateTitleViewHolder(ViewGroup parent) {
        View view = mInflater.inflate(R.layout.item_delivery_title, parent, false);
        return new IndexVH(view);
    }

    @Override
    public RecyclerView.ViewHolder onCreateContentViewHolder(ViewGroup parent) {
        View view = mInflater.inflate(R.layout.item_delivery_content, parent, false);
        return new ContentVH(view);
    }

    @Override
    public void onBindTitleViewHolder(RecyclerView.ViewHolder holder, String indexTitle) {
        IndexVH vh = (IndexVH) holder;
        vh.tvIndex.setText(indexTitle);
    }

    @Override
    public void onBindContentViewHolder(RecyclerView.ViewHolder holder, ExpressBean entity) {
        ContentVH vh = (ContentVH) holder;
        vh.tvDeliveryName.setText(entity.getExpressCorpName());
//        ImageLoaderUtils.displayCircle(mContext, vh.ivDeliveryLogo, AppConstant.IMAGE_URL_TEST);
    }

    private class IndexVH extends RecyclerView.ViewHolder {
        TextView tvIndex;

        public IndexVH(View itemView) {
            super(itemView);
            tvIndex = itemView.findViewById(R.id.tv_index);
        }
    }

    private class ContentVH extends RecyclerView.ViewHolder {
        TextView tvDeliveryName;
//        ImageView ivDeliveryLogo;

        public ContentVH(View itemView) {
            super(itemView);
            tvDeliveryName = itemView.findViewById(R.id.tv_delivery_name);
//            ivDeliveryLogo = (ImageView) itemView.findViewById(R.id.iv_delivery_logo);
        }
    }
}
